﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SplitOS
{
    public static class Validation
    {
        public static void validate(string __com)
        {
            string com = __com;
            string lcom = __com.Trim().ToLower();

            if (lcom.Split(' ')[0] == "echo") Console.WriteLine(com.Remove(0, 5));
            else if (lcom.Split(' ')[0] == "print") Console.WriteLine(com.Remove(0, 6));
            else if (lcom == "cls" || lcom == "clear" || lcom == "clearscreen") { Console.Clear(); Core.PrintLogo(); }
            else if (lcom == "osal" || lcom == "sal") SplitOS.OSAL.Interpreter.Start();
            else if (OSAL.INTERNAL.StringTools.StartsWith(lcom, "sal run ")) OSAL.Storage.RunApplication(lcom.Remove(0, 8));
            else if (lcom == "gui") GUI.GUI.Initialize();
            else if (lcom == "help") Commands.help();
            else if (lcom == "strobo") StroboGUI.Initialize();
            else if (lcom == "shutdown") Commands.shutdown();
            else if (lcom == "reboot" || lcom == "restart") Commands.reboot();
        }
    }

    public static class Commands
    {
        public static void shutdown() { ACPI.Shutdown(); }
        public static void reboot() { ACPI.Reboot(); }
        public static void help()
        {
            if (Utils.Language.lang == Utils.Language.Languages.English)
            {
                Console.Clear(); Core.PrintLogo();
                Console.WriteLine("-------------------< SplitOS  Help >--------------------");
                Console.WriteLine("help\n   print a short command-reference to the screen");
                Console.WriteLine("cls\n   clear the console");
                Console.WriteLine("echo [Text]\n   print a text to the console");
                Console.WriteLine("OSAL\n   start the 'Open SAL' Interpreter");
                Console.WriteLine("GUI\n   enter the experimental GUI");
                Console.WriteLine("shutdown\n   power-off your computer");
                Console.WriteLine("--------------------------------------------------------");
                Console.WriteLine("----Press-any-key-to-continue---------------------------");
                Console.Read();
                Console.Clear(); Core.PrintLogo();
            }
            if (Utils.Language.lang == Utils.Language.Languages.German)
            {
                Console.Clear(); Core.PrintLogo();
                Console.WriteLine("-------------------< SplitOS Hilfe >--------------------");
                Console.WriteLine("help\n   Zeige eine kurze Kommando-Referenz an");
                Console.WriteLine("cls\n   Leere die Konsole");
                Console.WriteLine("echo [Text]\n   Schreibe einen Text auf die Konsole");
                Console.WriteLine("OSAL\n   Starte den 'Open SAL' Interpreter");
                Console.WriteLine("GUI\n   Betrete den experimentellen Grafischen Modus");
                Console.WriteLine("shutdown\n   Schalte den Computer aus");
                Console.WriteLine("--------------------------------------------------------");
                Console.WriteLine("----Druecke-eine-Taste-um-fortzufahren------------------");
                Console.Read();
                Console.Clear(); Core.PrintLogo();
            }
        }
    }
}